// OSCClass loop back processing test sketch (client side)
// OSCClass version 1.0.1 (Arduino ver0014)
// need oscP5 Library
// Copyright (c) recotana(http://recotana.com).  All right reserved.

//click inside black window -> send OSC message
//display -> loop back log
 
import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress arduinoAddress;

void setup() {
  size(400,400);
  frameRate(25);

  oscP5 = new OscP5(this,10000);
  
 
  arduinoAddress = new NetAddress("192.168.0.99",10000);
}


void draw() {
  background(0);  
}

void mousePressed() {

  OscMessage testMesssage1 = new OscMessage("/ard/test1"); 
  testMesssage1.add(1.2); 
  oscP5.send(testMesssage1, arduinoAddress);
 
  OscMessage testMesssage2 = new OscMessage("/ard/test2"); 
  testMesssage2.add(5); 
  oscP5.send(testMesssage2, arduinoAddress);
 
  OscMessage testMesssage3 = new OscMessage("/ard/test3"); 
  testMesssage3.add(-100);
  testMesssage3.add(123.321);
  oscP5.send(testMesssage3, arduinoAddress);
 
  
}



void oscEvent(OscMessage oscMessage) {

  print("received!");
  print(" "+oscMessage.addrPattern());
  String typeTag = oscMessage.typetag();
  print(" "+typeTag);
  print(" args:");
  
  for(int i=0 ; i<typeTag.length() ; i++){

   switch( typeTag.charAt(i) ){
     
    case 'i': print( oscMessage.get(i).intValue() );
      break;

    case 'f': print( oscMessage.get(i).floatValue() );
      break;
 
    case 's': print( oscMessage.get(i).stringValue() );
      break;     
     
   }
  
    print(" ");
  }
  println("");
  
}
